<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title><{$title}> - <{$title_desc}></title>
<link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<{if defined('DEBUG_CSS') && DEBUG_CSS}>
<{css src="framework.css"}>
<{css src="default/style.css"}>
<{else}>
<{css src="default/style_min.css"}>
<{/if}>

<{foreach from=$theme_css item="desktop_theme_css_file"}>
<link rel="stylesheet" href="<{$desktop_theme_css_file}>">
<{/foreach}>
<{lang_css src="lang.css" app="desktop"}>
<{desktop_header}>

<{assign var=desktop_sideleft value="desktop_{$uname}_sideleft"}>
<script>
startTime = (new Date).getTime();

currentWorkground = null;

/*商店事件、状态 推送包*/
shopeEvents = {};
SESS_ID=null;
SHOPBASE='<{$shop_base}>';
SHOPADMINDIR='<{$shopadmin_dir}>';
DESKTOPRESURL='<{$env.app.res_url}>';
DESKTOPRESFULLURL='<{$env.app.res_full_url}>';
CURRENTUSER =  '<{$uname}>';
BREADCRUMBS ='0:0';
window.loadedPart = [1,0,startTime];
</script>
</head>
<body>
<noscript>
  <div class='noscript error'>
    <{t}>您好，要正常运行，浏览器必须支持Javascript<{/t}>
  </div>
</noscript>
<div style="display:none;">
  <iframe src='<{$env.base_url}>/app/desktop/view/tpl.html' id='tplframe' class='hide'></iframe>
  <iframe src='<{$env.base_url}>/app/desktop/view/about.html' name='download' id='downloadframe' class='hide'></iframe>
  <iframe src='<{$env.base_url}>/app/desktop/view/about.html' name='upload' id='uploadframe' class='hide'></iframe>
</div>
<div class="msgbox" id="messagebox"></div>
<div class="wrapper clearfix" id='body' style='visibility:hidden'>
  <div id="aside" class="aside">
    <div class="aside-head">
      <h1 class="logo">
        <{if $ec_deploy.publish_version == 'ecstore' && $ec_deploy.publish_version== 'quick' }>
        <{assign var=ver value=快启版}>
        <{elseif $ec_deploy.publish_version == 'ONex_ECStore_quick' }>
        <{assign var=ver value=快启版}>
        <{elseif $ec_deploy.publish_version == 'ONex_ECStore' ||  $ec_deploy.publish_version == 'ecstore' }>
        <{assign var=ver value=标准版}>
        <{else}>
        <{assign var=ver value=专业版}>
        <{/if}>
        <a href="?ctl=dashboard&act=index" title="<{t}>ECStore<{$ver}><{/t}>"><img src="<{$env.app.res_url}>/css/default/images/logo@2x.png"></a>
        <img height='0' width='0' style="position: absolute;" src="http://tongji.eadian.com/ecstore.jpg">
      </h1>
    </div>
    <div class="aside-main nav">
      <ul>
        <{foreach from=$fav_menus item=item  key=key}>
          <{if $menus.menu.$item}>
          <{assign var=menu_group value=$menus.menu.$item}>
            <li class="wg" mid="<{$menus.workground.$item.menu_id}>">
                <a href="index.php?<{$menus.workground.$item.menu_path}>" <{if $menus.workground.$item.target}>target="<{$menus.workground.$item.target}>"<{/if}>><i class="menu-<{$menus.workground.$item.menu_logo_class}>"></i><span><{t}><{$menus.workground.$item.menu_title}><{/t}></span></a>
            </li>
        <{/if}>
        <{/foreach}>
        <li class="wg setting" mid="-1">
          <a href="index.php?app=b2c&ctl=admin_setting">
            <i class="menu-set"></i>
            <span>设置</span>
          </a>
        </li>
      </ul>
    </div>
    <div class="aside-foot"><a target="command::{title:'<{t}>检查更新<{/t}>'}" title="检查更新" class="lnk" href="?ctl=appmgr&act=fetchindex">V<{$product_version}></a></div>
  </div>
  <div id="sections" class="sections">
    <div class="header" id="header">
      <div class="top-bar" id="topbar">
        <{if $desktop_active_url}><{$desktop_active_url}><{/if}>
        <div class="head-user">
          <img class="avatar" src="<{$env.app.res_url}>/css/default/images/nav/admin.svg" alt="avatar">
          <a href="index.php?ctl=dashboard&act=profile" target="dialog::{width:463,height:280,title:'<{t}>设置<{/t}>'}" title="设置"><{$uname}></a> &nbsp;
          <span class="head-license">
            <a href="<{$certificate_url}>" id="license" target="_blank" style="display:none;"></a>
          </span>
          &nbsp;&nbsp;
          <a href="index.php?ctl=passport&act=logout" class="lnk"><{t}>退出<{/t}></a>
        </div>
        <div class="head-setting">
          <{$desktop_menu}>
          <div class="rpcnotify frt" style="display:none">
            <a href='index.php?ctl=rpcnotify&act=index'><{t}>系统通知<{/t}></a><i class="notify_num"></i>
          </div>
        </div>
      </div>
    </div>

    <div class="container clearfix" id="container">
      <div class="side <{if $env.cookie[$desktop_sideleft] == 'OFF-SHOW'}>hide<{/if}>" id="side">
        <div class="side-inner">
          <div class="side-content">
          </div>
        </div>
      </div>
      <div class='workground' id='workground'>
        <div class='content-head' style="font-size:0;height:0;"></div>
        <div class='content-main' id='main'></div>
        <div class='content-foot' style="font-size:0;height:0;"></div>
      </div>

      <div class="side-r hide" id="side-r">
        <div class="side-r-resize" id="side-r-resize">&nbsp;</div>
        <div class="side-r-top clearfix content-padded">
          <div class="side-r-title flt f-14"></div>
          <span class="frt side-r-close pointer"><i class="fa fa-times"></i></span>
        </div>
        <div class="side-r-head"></div>
        <div id="side-r-content" class="side-r-content" conatainer="true" style="overflow:auto">
        </div>
        <div class="side-r-foot" style="font-size:0;height:0;"></div>
      </div>
    </div>
  </div>
</div>

<{lang_script src="lang.js"}>
<{script src="loader.js" pdir="js_mini"}>

<{if defined('DEBUG_JS') && DEBUG_JS}>
  <{script src="moo.js"}>
  <{script src="moomore.js"}>
  <{script src="mooadapter.js"}>
  <{script src="jstools.js"}>
  <{script src="coms/wpage.js"}>
  <{script src="coms/messagebox.js"}>
  <{script src="coms/dialog.js"}>
  <{script src="coms/validate.js"}>
  <{script src="coms/dropmenu.js"}>
  <{script src="coms/finder.js"}>
<{else}>
  <{script src="moo_min.js" pdir="js_mini"}>
  <{script src="tools_min.js" pdir="js_mini"}>
  <{script src="coms/finder.js" asycn="true" pdir="js_mini"}>
<{/if}>

<script>
(function(){
  <{if defined('DEBUG_JS') && DEBUG_JS}>
    var js_path='<{$env.app.res_url}>/js/';
    var timer = '?<{$smarty.now}>';
  <{else}>
    var js_path='<{$env.app.res_url}>/js_mini/';
    var timer = '';
  <{/if}>

    var hs = {
        'cmdrunner':{path:js_path+'coms/cmdrunner.js'+timer,type:'js'},
        'historyMan':{path:js_path+'coms/hst.js'+timer,type:'js'},
        'autocompleter':{path:js_path+'coms/autocompleter.js'+timer,type:'js'},
        'uploader':{path:js_path+'coms/uploader.js'+timer,type:'js'},
        'modedialog':{path:js_path+'coms/modedialog.js'+timer,type:'js'},
        'pager':{path:js_path+'coms/pager.js'+timer,type:'js'},
        <{if defined('DEBUG_JS') && DEBUG_JS}>
        'colorpicker':{path:js_path+'coms/colorpicker.js'+timer,type:'js'},
        'editor_style_1':{path:js_path+'coms/editor_style_1.js'+timer,type:'js',requires:['picker']},
        <{/if}>
        'picker':{path:js_path+'coms/datapicker.js'+timer,type:'js',requires:['colorpicker']},
        'editor':{path:js_path+'coms/editor.js'+timer,type:'js',requires:['editor_style_1']}
    };
    Object.each(hs,function(v,k){Ex_Loader.add(k,v);});

    if(window.ie6)Ex_Loader(js_path+'fixie6.js'+timer);
})();

var LAYOUT = {
    aside: $('aside'),
    head: $('header'),
    container: $('container'),
    side: $('side'),
    workground: $('workground'),
    content_main: $('main'),
    content_head: $E('#workground .content-head'),
    content_foot: $E('#workground .content-foot'),
    side_r: $('side-r'),
    side_r_content:$('side-r-content'),
};

/*init  script

this Function will run at 'loadedPart[1]==loadedPart[0]'
*/
var initDesktop = function() {

    window.resizeLayout = fixLayout = function() {

        var _NUM = function(num){
            num =  isNaN(num)?0:num;
            if(num<0)num=0;
            return num;
        };
        var mw=0,mh=0;
        var winSize = window.getSize();
        var secWidth = winSize.x - LAYOUT.aside.getSize().x;
        var containerHeight = winSize.y - LAYOUT.head.getSize().y;
        LAYOUT.container.setStyle('height',_NUM(containerHeight-LAYOUT.container.getPatch().y));
        LAYOUT.container.setStyle('width',_NUM(secWidth.limit(960, 2000)));
        LAYOUT.aside
        .getElement('.aside-main')
          .setStyle('height', winSize.y - LAYOUT.aside.getElement('.aside-head').getSize().y - LAYOUT.aside.getElement('.aside-foot').getSize().y);

        LAYOUT.workground.setStyle('width',_NUM(
            secWidth-
            LAYOUT.side.getSize().x-
            LAYOUT.side_r.getSize().x)
        ).setStyle('left',LAYOUT.side.offsetWidth);

        LAYOUT.content_main.setStyles({'height':
            (mh=_NUM(containerHeight -
            LAYOUT.content_head.getSize().y -
            LAYOUT.content_foot.getSize().y -
            LAYOUT.workground.getPatch().y + 20)),
            'width':(mw=_NUM(LAYOUT.workground.getSize().x-LAYOUT.workground.getPatch().x))
        }).fireEvent('resizelayout',[{x:mw,y:mh}]);

        if(!LAYOUT.side_r.hasClass('hide')){
            if(!LAYOUT.side_r.get('widthset'))
                LAYOUT.side_r.setStyle('width',_NUM((secWidth*0.15).limit(0,secWidth)));
            LAYOUT.side_r_content.setStyle('height',
                _NUM(containerHeight-
                LAYOUT.side_r.getElement('.side-r-top').getSize().y-
                LAYOUT.side_r.getElement('.side-r-head').getSize().y-
                LAYOUT.side_r.getElement('.side-r-foot').getSize().y-
                LAYOUT.side_r_content.getPatch().y
                // -LAYOUT.side_r.getPatch().y
              )
            );
            LAYOUT.side_r.setStyle('left',secWidth - LAYOUT.side_r.offsetWidth);
        }

        var cls = (location.href.match(/app=([^&]+)/) ? location.href.match(/app=([^&]+)/)[1] + '-' : '') + (location.href.match(/ctl=([^&]+)/) ? location.href.match(/ctl=([^&]+)/)[1].replace(/_/g, '-') : '');
        LAYOUT.workground.set('class', 'workground ' + cls);
    };

    resizeLayout();

    Side_R = new Class({
        Implements: [Options, Events],
        options: {
            onShow: $empty,
            onHide: $empty,
            onReady: $empty,
            isClear:true,
            width:false
        },
        initialize: function(url, opts) {
            this.setOptions(opts);
            var panel = this.panel = $('side-r');
            var container = this.container = $('side-r-content');
            var trigger = this.options.trigger;

            if(trigger&&!trigger.retrieve('events',{})['dispose']) {
                 trigger.addEvent('dispose',function(){
                     panel.addClass('hide');
                     container.empty();
                     panel.removeProperty('widthset').store('url','');
                    });
              }


            if(panel.retrieve('url','') == url)return;

            if (url) {
                this.showSide(url);
            } else {
                throw Exception('NO TARGET URL');
                return;
            }

            var btn_close = panel.getElement('.side-r-close');
            var _title = panel.getElement('.side-r-title');

            _title.set('html',this.options.title||"");

            if(btn_close){
                btn_close.removeEvents('click').addEvent('click', this.hideSide.bind(this));
            }

        },
        showSide: function(url) {
            this.cleanContainer();

            var _this = this;
            if(_this.options.width&&!_this.panel.get('widthset')){
                _this.panel.set({'widthset':_this.options.width,styles:{width:_this.options.width}});
            }
            _this.panel.removeClass('hide');
            _this.fireEvent('show');
            window.resizeLayout();
            if(this.cache)return;
            W.page(url,{
                update:_this.container,
                render:false,
                onRequest: function() {
                    _this.panel.addClass('loading');
                },
                onComplete: function() {
                    _this.panel.removeClass('loading');
                    _this.fireEvent('ready', $splat(arguments));
                    _this.panel.store('url',url);
                    _this.container.style.height = (_this.container.style.height.toInt()-_this.container.getPrevious().getSize().y-_this.container.getNext().getSize().y)+'px';

                }
            });
        },
        hideSide: function() {
            this.panel.addClass('hide');
            window.resizeLayout();
            this.cleanContainer();
            this.fireEvent('hide');
        },
        cleanContainer: function() {
            this.panel.store('url','');
            if(this.options.isClear)this.container.empty();
        }
    });


    new Drag($('side-r-resize'), {
        modifiers: {
            'x': 'left',
            'y':false
        },
        onBefore:function(el){
            el.addClass('side-r-resize-ing');
        },
        onDrag: function(el) {
            el.addClass('side-r-resize-ing');
        },
        onComplete: function(el) {
            el.removeClass('side-r-resize-ing');

            var left = el.getStyle('left');
                left = left.toInt();
            var _w =  LAYOUT.side_r.style.width.toInt()-(left-(-6));
            LAYOUT.side_r.style.width = _w+'px';
            LAYOUT.side_r.set('widthset',_w);
            el.style.left = '-6px';
            resizeLayout();
        }
    });


    /*MODAL PANEL*/
    MODALPANEL = {
        createModalPanel:function(){
            var mp = new Element('div',{'id':'MODALPANEL'});
            var mpStyles = {
                'position': 'absolute',
                'background': '#333333',
                'width': '100%',
                'display':'none',
                'height': window.getScrollSize().y,
                'top': 0,
                'left': 0,
                'zIndex': 65500,
                'opacity': .4
            };
            this.element = mp.setStyles(mpStyles).inject(document.body);
            return this.element;
        },
        show:function(){
            var panel = this.element = this.element||this.createModalPanel();
            panel.setStyles({
                'width': '100%',
                'height': window.getScrollSize().y
            }).show();
        },hide:function(){
            if(this.element)this.element.hide();
        }
    };


    var windowResizeTimer = 0;
    window.addEvent('resize',function() {
        $clear(windowResizeTimer);
        windowResizeTimer = window.resizeLayout.delay(200);

        if(MODALPANEL.element&&MODALPANEL.element.style.display!='none'){
                MODALPANEL.element.setStyles({
                       'height':window.getScrollSize().y
                });
        }

    });

    var fixSideToggler = (function(){
        return arguments.callee;
    })();

    fixSideLeft = function(act){
        if(Cookie.read('desktop_'+CURRENTUSER+'_sideleft'))act='add';
        LAYOUT.side[act+'Class']('hide');
        window.resizeLayout();
    };

<{if count($fav_menus)>0}>
  /*顶部菜单处理*/
  void function(){
    var _timer = 0;
    var _mouse = true;
    var workMenus = LAYOUT.aside.getElements('.nav li');
    var getCurWgMenu = function() {
      return LAYOUT.aside.getElement('[mid=' + BREADCRUMBS.split(":")[0] + ']');
    }

    workMenus.addEvents({
      'mouseenter':function(){
        _mouse=true;
        $clear(_timer);
        var wg = this;
        var cwg = getCurWgMenu();
        if(cwg){
          if(Slick.uidOf(wg)!=Slick.uidOf(cwg)){
            cwg.removeClass('current');
          }
        }
        wg.addClass('current').getSiblings().removeClass('current');
      },
      'mouseleave':function(e){
        if(!_mouse)return;
        var wg = this;
        var cwg = getCurWgMenu();
        if(cwg&&e){
          if(Slick.uidOf(wg)!=Slick.uidOf(cwg)){
            _timer = cwg.addClass.delay(0,cwg, 'current');
            wg.removeClass('current');
          }
        } else {
          var link = wg.getElement('a').href,
              link = link.slice(link.indexOf('&')+ 5,link.length),
              url = location.href,
              url = url.slice(url.indexOf('&')+ 5,url.length);
          if(link == url){
            wg.addClass('current');
          }else{
            wg.removeClass('current');
            $$('.setting').addClass('current');
          }
        }
      }
    });
 }();
<{/if}>

    /*每 30秒 同步一下后台 的事项*/
    TaskRemote = {
        url: "index.php?ctl=default&act=status",
        timer: 30000,
        delay: 0,
        stop:function(){
            $clear(this.delay);
        },
        start:function(){
            this.delay = this.doit.delay(this.timer, this);
        },
        init: function() {
            var _this = this;
            this.request = (new Request.HTML({
                url:this.url,
                onSuccess: function(nodes, elements, responsetext, javascript) {
                    $clear(_this.delay);
                    _this.delay = _this.doit.delay(_this.timer, _this);
                },
                onCancel: function() {
                    _this.delay = _this.doit.delay(_this.timer, _this);
                },
                onFailure: function() {
                    _this.delay = _this.doit.delay(_this.timer * 2, _this);
                }
            }));
            return this;
        },
        doit: function(_chain) {

            _chain =$type(_chain)=='function'?_chain : $empty;

            return this.request.post({
                events: shopeEvents
            }).chain(_chain);
        }
    };
    TaskRemote.init().start();


    EventsRemote = new Request({url:'index.php?ctl=default&act=desktop_events'});

    var keyObj = <{$keyboard_setting_json}>;
    $(window.gecko?document.documentElement:document.body).addEvent('keydown',function(e){
        if(e.target==this){
            if(e.code==32)e.stop();
            Hotkey.init(e,keyObj);
        }
    });

    /** 获取授权证书 **/

    var _timer,_request = function(){
            new Request({
                url:'index.php?app=desktop&ctl=default&act=set_open_api',
                method:'post',
                onComplete:function(res){
                    new Asset.image(res,{
                            onload:function(img){
                                $('license').show().adopt(img);
                                $clear(_timer);
                            },
                            onerror:function(){
                                _timer = _request.delay(30000);
                            }
                    });
                }
            }).send();
        };
    _request();



     Xtip = new Tips({tip:'tip_Xtip',fixed:true,offset: {x: 24, y: -15},onBound:function(bound){
        if(bound.x2){
            this.tip.getElement('.tip-top').addClass('tip-top-right');
            this.tip.getElement('.tip-bottom').addClass('tip-bottom-right');
        }else {
            this.tip.getElement('.tip-top').removeClass('tip-top-right');
            this.tip.getElement('.tip-bottom').removeClass('tip-bottom-right');
        }
     }});

    /*default Action
        ctl=dashboard&act=index
    */
    W = new Wpage({},'ctl=dashboard&act=index').chain(function(){
        $('body').setStyles({visibility:'visible'});
    });


    W.render(document.body);

    (function(){
        if(!Browser.Platform.ios)return;
        var start = {x:0,y:0};
        var fx = new Fx.Scroll('main',{link:'cancel'});
        $('main').addEvents({
                touchstart:function(e){
                    start = e.page;
                },
                touchmove:function(e){
                    e.stop();
                    fx.start(this.scrollLeft-(e.page.x-start.x),this.scrollTop-(e.page.y-start.y));
                }
        });
    })();

};//function end;

window.addEvent('domready',initDesktop);


function _get_rpcnotify_num(obj) {
    W.page('index.php?app=desktop&ctl=rpcnotify&act=read',{method:'POST',onComplete:function(){
                var notify=$E('#topbar .notify_num');
                if(notify){
                    var msg=notify.get('text'),n;
                    n=msg.substring(1,msg.length-1);
                    n=n-1>0?'('+(n-1)+')':'';
                    notify.set('text',n);
                }
            },data:{id:$(obj).getParent('tr').getElement('input').get('value')}
       });
}



function confirm_init_point(url){
  if(confirm('因积分接口更新，初始化积分数据到CRM前请确认您绑定的CRM版本不低于2.2.8，否则可能会出现积分数据不统一的状况'))
  {
    if(confirm('请再次确认您绑定的CRM版本不低于2.2.8'))
    {
      new Request({
          url:url,
          onSuccess:function(rs) {
              try{
                rs = JSON.decode(rs);
              }catch(e){}

              if(rs.error) return new MessageBox(rs.error,{autohide:true});
              new MessageBox(rs.success,{autohide:true});
          }

          }).get();
      return true;
    }else{
      return false;
    }
  }
  else
  {
    return false;
  }
}

var NOTEPOP = new NotePop();
</script>
<{foreach from=$theme_scripts item="desktop_theme_js"}>
<script type="text/javascript" src="<{$desktop_theme_js}>"></script>
<{/foreach}>
<{desktop_footer}>
</body>
</html>
